package test;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class test4 {
	public static void main(String[] args) {
		SimpleDateFormat sf  =new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat sf1  =new SimpleDateFormat("M-d");
		//Date starttime=StringToDate("2013-09-25","yy-mm-dd");
		Date endtime=StringToDate("2013-10-25","yyyy-MM-dd");
		 GregorianCalendar gc=new GregorianCalendar();
		  
		
		long day=getDaySub( "2013-09-25", "2013-10-25");
		for(int i=0;i<=day;i++){
			//System.out.println(i);
			gc.setTime(endtime);
			gc.add(5,-i);
			System.out.println(sf1.format(gc.getTime()));
		}
		 
	}
	public static Date StringToDate(String dateStr,String formatStr){
		DateFormat dd=new SimpleDateFormat(formatStr);
		Date date=null;
		try {
			date = dd.parse(dateStr);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
	public static long getDaySub(String beginDateStr,String endDateStr)
    {
        long day=0;
        java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");   
        java.util.Date beginDate;
        java.util.Date endDate;
        try
        {
            beginDate = format.parse(beginDateStr);
            endDate= format.parse(endDateStr);   
            day=(endDate.getTime()-beginDate.getTime())/(24*60*60*1000);   
            //System.out.println("相隔的天数="+day);  
        } catch (ParseException e)
        {
            // TODO 自动生成 catch 块
            e.printStackTrace();
        }  
        return day;
    }
}
